//
//  ChargeAgencyController.m
//  Wisdom Bank
//
//  Created by rimi on 15/10/10.
//  Copyright (c) 2015年 wlc. All rights reserved.
//  代理缴费服务

#import "ChargeAgencyController.h"
#import "CustomTableViewCell.h"

@interface ChargeAgencyController () <UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong)UIButton *shootCodeBtn;
@property (nonatomic, strong)UITextField *textField;
@property (nonatomic, strong)UIButton *identifyBtn;
@property (nonatomic, strong)UILabel *amountLabel;
@property (nonatomic, strong)UIButton *sureBtn;
@property (nonatomic, strong)UIButton *selectAllBtn;
@property (nonatomic, strong)UIButton *surePaymentBtn;
@property (nonatomic, strong)UITableView *formTableView;
@end

@implementation ChargeAgencyController

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.view.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:self.shootCodeBtn];
    [self addPaymentProject];
    [self.view addSubview:self.textField];
    [self.view addSubview:self.identifyBtn];
    [self.view addSubview:self.sureBtn];
    [self.view addSubview:self.selectAllBtn];
    [self.view addSubview:self.surePaymentBtn];
    [self.view addSubview:self.formTableView];
}


- (void)addPaymentProject{
    
    NSArray *arrImage1 = @[@"未选中-水.png",@"未选中-电.png",@"未选中-煤气.png",@"未选中-电信.png",@"未选中-联通.png",@"未选中-移动.png",@"未选中-东方有线.png"];
    NSArray *arrImage2 = @[@"选中 水.png",@"选中 电.png",@"选中 煤气费.png",@"选中 电信.png",@"选中 联通.png",@"选中 移动.png",@"选中 东方有线.png"];
    for (int i = 0; i < arrImage1.count; i++) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[UIImage imageNamed:arrImage1[i]] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:arrImage2[i]] forState:UIControlStateDisabled];
        btn.frame = CGRectMake(60 + (i%4)*(114+25), 100 + (i/4)*(60+35), 114, 70);
        btn.tag = i;
        btn.highlighted = NO;
        [btn addTarget:self action:@selector(respondsToQueryBtn:) forControlEvents:UIControlEventTouchDown];
        [self.view addSubview:btn];
    }
    
}

#pragma mark - responds
- (void)respondsToQueryBtn:(UIButton *)sender{

}

#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *const kUITableViewCellIdentifier = @"cellIdentifier";
    CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kUITableViewCellIdentifier];
    
    if (!cell) {
        cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kUITableViewCellIdentifier];
    }
    cell.number.text = @"你是谁";
    cell.type.text = @"我是我";
    cell.amount.text = @"我是谁";
    return cell;
}

#pragma mark - <UITableViewDelegate>
// 设置头部视图高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 42;
}

/**< 自定义头部视图 */
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc]init];
    
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"缴费类型.png"]];
    imageView.frame = CGRectMake(0, 0, 575, 42);
    [headerView addSubview:imageView];
    return headerView;
}

// 设置尾部视图高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 42;
}

/**< 自定义尾部视图 */
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footView = [[UIView alloc]init];
    footView.backgroundColor = COLOR_RGB(218, 203, 160, 1);
    UILabel *label = [[UILabel alloc]init];
    label.frame = CGRectMake(400, 0, 140, 42);
    label.text = @"总金额： 0.00元";
    [footView addSubview:label];
    return footView;
}




#pragma mark -getter
- (UITableView *)formTableView{

    if (!_formTableView) {
        _formTableView = ({
            UITableView *tableView = [[UITableView alloc]init];
            tableView.frame = CGRectMake(70, 482, 575, 300);
            tableView.backgroundColor = [UIColor clearColor];
            tableView.delegate = self;
            tableView.dataSource = self;
            tableView;
        
        });
    }
    return _formTableView;
}


- (UIButton *)shootCodeBtn{
    
    if (!_shootCodeBtn) {
        _shootCodeBtn = ({
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(70, 300, 112, 50);
            [btn setImage:[UIImage imageNamed:@"拍码-1.png"] forState:UIControlStateNormal];
            btn.layer.cornerRadius = 5;
            btn;
        });
    }
    return _shootCodeBtn;
}

- (UITextField *)textField{

    if (!_textField) {
        _textField = ({
            UITextField *textField = [[UITextField alloc]init];
            textField.frame = CGRectMake(200, 310, 336, 30);
            textField.backgroundColor = [UIColor whiteColor];
            textField;
        });
    }
    return _textField;
}

- (UIButton *)identifyBtn{
    
    if (!_identifyBtn) {
        _identifyBtn = ({
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(545, 310, 80, 30);
            [btn setImage:[UIImage imageNamed:@"条码识别.png"] forState:UIControlStateNormal];
            btn.layer.cornerRadius = 5;
            btn;
        });
    }
    return _identifyBtn;
}

- (UIButton *)sureBtn{
    
    if (!_sureBtn) {
        _sureBtn = ({
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(250, 430, 110, 40);
            [btn setImage:[UIImage imageNamed:@"确定1.png"] forState:UIControlStateNormal];
            btn.layer.cornerRadius = 5;
            btn;
        });
    }
    return _sureBtn;
}

- (UIButton *)selectAllBtn{
    
    if (!_selectAllBtn) {
        _selectAllBtn = ({
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(165, 790, 110, 40);
            [btn setImage:[UIImage imageNamed:@"全选.png"] forState:UIControlStateNormal];
            btn.layer.cornerRadius = 5;
            btn;
        });
    }
    return _selectAllBtn;
}

- (UIButton *)surePaymentBtn{
    
    if (!_surePaymentBtn) {
        _surePaymentBtn = ({
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(355, 790, 110, 40);
            [btn setImage:[UIImage imageNamed:@"确定缴费.png"] forState:UIControlStateNormal];
            btn.layer.cornerRadius = 5;
            btn;
        });
    }
    return _surePaymentBtn;
}

- (void)dealloc{
    
    NSLog(@"代理缴费被销毁了！");
}


@end
